import databases
import sqlalchemy

from pydantic import BaseModel

from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

from sqlalchemy import Boolean, Column, ForeignKey, Integer, String,Text



Base = declarative_base()


DATABASE_URL = "postgresql://postgres:root@localhost:5432/blog"

database = databases.Database(DATABASE_URL)
metadata = sqlalchemy.MetaData()

articles = sqlalchemy.Table(
    "article",
    metadata,
    sqlalchemy.Column("id", sqlalchemy.Integer, primary_key=True),
    sqlalchemy.Column("title", sqlalchemy.String),
    sqlalchemy.Column("content", sqlalchemy.Text),
)


class Article(BaseModel):
    id: int
    title: str
    content: str



engine = sqlalchemy.create_engine(
    DATABASE_URL
)
metadata.create_all(engine)

